<?php
class PaymentAction extends CommonAdminAction {
    public function _initialize() {
        parent::_initialize();
        $this->setNav(array(
            array("支付账单流水", __URL__),
        ));
    }
    
    /**
     * 新增操作
     * @access public
     * @return void
     * @throws ThinkExecption
     */
    public function create() {
        // 公司下拉框
        $companyList = $this->companyList();
        // 个人下拉框
        $personList = $this->personList();
        $this->assign('companyList', $companyList);
        $this->assign('personList', $personList);
        $this->display();
    }
    
    /**
     * 更新操作
     * @access public
     * @return void
     * @throws ThinkExecption
     */
    function update() {
        $vo = $this->_update();
        if (!$vo) {
            $this->error("未找到更改的目标");
        }
        
        
        // 公司下拉框
        $companyList = $this->companyList();
        // 个人下拉框
        $personList = $this->personList();
        $this->assign('companyList', $companyList);
        $this->assign('personList', $personList);
        
        $this->assign('vo', $vo);
        $this->display();
    }
    
    /**
     * 更新: 根据主键取得项目
     * @access public
     * @return void
     * @throws ThinkExecption
     */
    protected function _update() {
        $name = $this->_getDBName();
        $model = M($name);
        $id = $_REQUEST [$model->getPk()];
        return $model->getById($id);
    }
    
    protected function companyList() {
        $company = M('company');
        $list = $company->select();
        return $list;
    }
    
    protected function personList() {
        $person = M('person');
        $list = $person->select();
        return $list;
    }
}
?>